package fr.hotel.main;

import java.io.IOException;
import java.util.List;
import java.util.Properties;

import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.SAXException;

import fr.hotel.bo.Client;
import fr.hotel.bo.Hotel;
import fr.hotel.constantes.IConstantes;
import fr.hotel.services.ServiceClient;
import fr.hotel.services.ServiceHotel;
import fr.hotel.utils.LectureProperties;

public class PositionLauncher {

	/**
	 * @param args
	 * @throws IOException
	 * @throws SAXException
	 * @throws ParserConfigurationException
	 */
	public static void main(String[] args) throws ParserConfigurationException,
			SAXException, IOException {
		Properties props = LectureProperties.getPropertiesResource();
		ServiceClient serviceClient = new ServiceClient();
		ServiceHotel serviceHotel = new ServiceHotel(serviceClient);
		Hotel hotel = serviceHotel.construction((String) props
				.get(IConstantes.PLAN));
		if (hotel.getNbChambre() == 0 || hotel.getChambres().isEmpty()) {
			System.out.println("Hotel vide");
			System.exit(0);
		}
		List<Client> clients = serviceClient.construction((String) props
				.get(IConstantes.CLIENT));
		if (clients.isEmpty()) {
			System.out.println("Clients vide");
			System.exit(0);
		}

		hotel = serviceHotel.alouerChambres(hotel, clients);
		System.out.println(hotel.afficherChambre());
	}
}
